<!--
 * @Descripttion: 过滤器V2
 * @version: 2.2
 * @Author: sakuya
 * @Date: 2021年7月30日14:48:41
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @LastEditTime: 2023-07-06 15:27:23
-->

<template>
	<span v-for="item in html" :class="'el-tag ' + item.key" :key="item.key">
		{{ item.value }}
	</span>
</template>
<script>
export default {
	name: "formatAuxiliaryDyeing",
	props: {
		params: Object,
	},
	data() {
		return {
			html: [],
		};
	},
	mounted() {
		this.getinit();
	},
	methods: {
		async getinit() {
			let typeName = [
				"",
				"el-tag--danger",
				"el-tag--warning",
				"el-tag--success",
				"el-tag--info",
			];
			const { column, row } = this.params;
			if (row[column.field]) {
				let dye_aux = row[column.field].split(",");
				await this.$API.system.dic.getDicData
					.get({ code: "EndCraft" })
					.then((craft) => {
						craft.data.forEach((element) => {
							if (dye_aux.includes(element.key)) {
								// html += "<span class='el-tag el-tag-" + typeName[element.key] + "'>" + element.name + "</span>";
								this.html.push({
									key: typeName[element.key],
									value: element.name,
								});
							}
						});
					});
			}
		},
	},
};
</script>
